<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
selection_test(
  '<div contenteditable dir="rtl">|Lorem <span dir="ltr">ipsum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">|Lorem <span dir="ltr">ipsum dolor sit</span> amet</div>',
  '8-0 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">L|orem <span dir="ltr">ipsum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">|L^orem <span dir="ltr">ipsum dolor sit</span> amet</div>',
  '8-1 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lo|rem <span dir="ltr">ipsum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">L|o^rem <span dir="ltr">ipsum dolor sit</span> amet</div>',
  '8-2 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lor|em <span dir="ltr">ipsum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lo|r^em <span dir="ltr">ipsum dolor sit</span> amet</div>',
  '8-3 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lore|m <span dir="ltr">ipsum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lor|e^m <span dir="ltr">ipsum dolor sit</span> amet</div>',
  '8-4 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem| <span dir="ltr">ipsum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lore|m^ <span dir="ltr">ipsum dolor sit</span> amet</div>',
  '8-5 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">|ipsum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem| ^<span dir="ltr">ipsum dolor sit</span> amet</div>',
  '8-6 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">i|psum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">|i^psum dolor sit</span> amet</div>',
  '8-7 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ip|sum dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">i|p^sum dolor sit</span> amet</div>',
  '8-8 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ips|um dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ip|s^um dolor sit</span> amet</div>',
  '8-9 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsu|m dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ips|u^m dolor sit</span> amet</div>',
  '8-10 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum| dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsu|m^ dolor sit</span> amet</div>',
  '8-11 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum |dolor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum| ^dolor sit</span> amet</div>',
  '8-12 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum d|olor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum |d^olor sit</span> amet</div>',
  '8-13 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum do|lor sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum d|o^lor sit</span> amet</div>',
  '8-14 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dol|or sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum do|l^or sit</span> amet</div>',
  '8-15 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolo|r sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dol|o^r sit</span> amet</div>',
  '8-16 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor| sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolo|r^ sit</span> amet</div>',
  '8-17 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor |sit</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor| ^sit</span> amet</div>',
  '8-18 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor s|it</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor |s^it</span> amet</div>',
  '8-19 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor si|t</span> amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor s|i^t</span> amet</div>',
  '8-20 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span>| amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor si|t^</span> amet</div>',
  '8-21 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> |amet</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span>| ^amet</div>',
  '8-22 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> a|met</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> |a^met</div>',
  '8-23 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> am|et</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> a|m^et</div>',
  '8-24 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> ame|t</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> am|e^t</div>',
  '8-25 rtl backward character');

selection_test(
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> amet|</div>',
  selection => selection.modify('extend', 'backward', 'character'),
  '<div contenteditable dir="rtl">Lorem <span dir="ltr">ipsum dolor sit</span> ame|t^</div>',
  '8-26 rtl backward character');
</script>
